package com.sunnada.btfvilg.controller;

import com.sunnada.btfvilg.common.response.Result;
import com.sunnada.btfvilg.common.response.ResultFactory;
import com.sunnada.btfvilg.entity.Sentence;
import com.sunnada.btfvilg.entity.User;
import com.sunnada.btfvilg.entity.Word;
import com.sunnada.btfvilg.model.request.UserRegParamVo;
import com.sunnada.btfvilg.model.response.UserListVo;
import com.sunnada.btfvilg.model.response.WordVo;
import com.sunnada.btfvilg.service.SentenceService;
import com.sunnada.btfvilg.service.UserService;
import com.sunnada.btfvilg.service.WordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


/**
 * 用户相关的接口
 */
@RestController
@RequestMapping("word")
@Api(tags = "danci")
public class WordController {

    @Autowired
    private WordService wordService;

    @Autowired
    private SentenceService sentenceService;

    @GetMapping("/nextWord")
    @ApiOperation(value = "获取下一个单词与意思", httpMethod = "GET")
    public Result<Word> nextWord() {
        Word word = wordService.nextWord();
        return ResultFactory.success("success", word);
    }

    @GetMapping("/reset")
    @ApiOperation(value = "reset list", httpMethod = "GET")
    public Result<WordVo> reset() {
        WordVo word = wordService.reset();
        return ResultFactory.success("success", word);
    }

    @GetMapping("/loadNewWord")
    @ApiOperation(value = "load New Word", httpMethod = "GET")
    public Result<Integer> loadNewWord() {
        Integer sum = wordService.loadNewWord();
        return ResultFactory.success("success", sum);
    }

    @GetMapping("/changeMode")
    @ApiOperation(value = "changeMode", httpMethod = "GET")
    public Result<Object> changeMode(String mode) {
        wordService.changeMode(mode);
        return ResultFactory.success("success", null);
    }

    //================================================================================

    @GetMapping("/nextSentence")
    @ApiOperation(value = "获取下一个句子与意思", httpMethod = "GET")
    public Result<Sentence> nextSentence() {
        Sentence sentence = sentenceService.nextSentence();
        return ResultFactory.success("success", sentence);
    }

    @GetMapping("/resetSentence")
    @ApiOperation(value = "reset list", httpMethod = "GET")
    public Result<Object> resetSentence() {
        sentenceService.resetSentence();
        return ResultFactory.success("success", null);
    }

    @GetMapping("/loadNewSentence")
    @ApiOperation(value = "loadNewSentence", httpMethod = "GET")
    public Result<Integer> loadNewSentence() {
        Integer sum = sentenceService.loadNewSentence();
        return ResultFactory.success("success", sum);
    }

}
